<template>
    <div class="containe">
        <div class="content-father"  v-loading="loading">
            <div class="content-son">
                <span class="authentication" v-if="item.supplyDemandType==='CAPABILITY_SERVICE'">能力服务</span>
                <span class="authentication" v-if="item.supplyDemandType==='EQUIPMENT_LEASING'" style="background-color: #a7cddc;">设备租赁</span>
                <span class="authentication" v-if="item.supplyDemandType==='LABOR_FORCE'" style="background-color: #dbc1a4;">劳动力</span>
                <span class="authentication" v-if="item.supplyDemandType==='OTHER_SERVICE'" style="background-color: #e3e3e3;">其他服务</span>
                <div class="house-day">
                    <span class="sdays">{{item.relativePulishDate}}</span>
                    <span v-if="item.matchStatus==='MATCHING'">剩余{{item.surplusDays}}天</span>
                    <span v-if="item.matchStatus==='FINISH'">已完成</span>
                    <span v-else-if="item.matchStatus==='OVERDUE'">已结束</span>
                    <span class="flspan">{{item.biddingRecords.length}}人参与</span>
                </div>
                <nuxt-link :to="`/qiao/d/detail/${item.id}`">
                    <div class="build-titles">
                        {{FILTER_FORMATER.wordNum(item.demandName,16)}}
                    </div>
                </nuxt-link>
                <nuxt-link :to="`/qiao/d/detail/${item.id}`">
                    <div class="nearnum">
                        {{FILTER_FORMATER.wordNum(item.demandInfo,40)}}
                    </div>
                </nuxt-link>
                <nuxt-link :to="`/qiao/d/detail/${item.id}`">
                    <div class="cont-bos">
                        <div class="moneys">
                            <div class="much" v-if="item.discussionFlag===1">商议</div>
                            <div class="much" v-else>￥{{tofloat(item.demandBudget)}}</div>
                            <div class="days">
                                <span v-if="item.supplyDemandType==='CAPABILITY_SERVICE'" class="days">{{item.expectedDuration+'天'}}</span>
                                <!-- <span v-else-if="item.supplyDemandType==='CAPABILITY_SERVICE'">{{'剩余'+item.surplusDays+'天'}}</span> -->
                                <span v-else-if="item.supplyDemandType!=='CAPABILITY_SERVICE'">{{item.createDate+'至'+item.biddingDeadline}}</span>
                                <span class="addres"></span>
                            </div>
                        </div>
                        <div class="much-btn">
                            <span class="mybtn" v-if="item.matchStatus=='FINISH'||item.matchStatus=='OVERDUE'">查看详情</span>
                            <span class="mybtn" v-else>我要报价</span>
                        </div>
                    </div>
                </nuxt-link>
                <div>
                    <nuxt-link :to="`/qiao/d/detail/${item.id}`">
                        <span class="flrt-smile" v-if="item.demandLocationProvince"> {{item.demandLocationProvince.label}} </span><span class="flrt-smile" v-if="item.demandLocationCity"> {{item.demandLocationCity.label}}</span>
                    </nuxt-link>
                    <span class="span-btn-item" @click="open53Server" style="float:right;">
                        <i class="icon icon-weixin_hover"></i>
                        <i class="icon icon-weixin"></i>
                        联系TA
                    </span>
                </div>
            </div>
            <div class="company">
                {{telfn(item.createUserName)}}
                <img class="img-qy" src="~/static/img/qd/qy.png" alt="" v-if="item.createUserRole==='ENTERPRISE'&&item.realStatus===2">
                <img class="img-qy" src="~/static/img/qd/geren.png" alt="" v-if="item.createUserRole==='PERSON'&&item.realStatus===2">
            </div>
        </div>
        <bidding
            v-if="isShowBidding"
            :bid-dialog-show="isShowBidding"
            :info="info"
            @dialogCallback="dialogCallback">
        </bidding>
        <div v-if="showNo" class="f-no-data">
            <i class="i-no-data icon icon-no-data"></i>
            <p>暂无数据</p>
        </div>
    </div>
</template>

<script lang="ts">
import {Component, Vue, Watch, Prop} from 'nuxt-property-decorator'
import {open53Server} from '~/method'
@Component({
    layout: 'qiao',
    components: {
    },
    head () {
        return {
            // title: '需求大厅-CIIP供需中心',
            // meta: [
            //     {hid: 'description', name: 'description', content: 'CIIP供需中心需求大厅可以找到建筑行业能力服务、设备租赁和劳动力的相关需求项目，发现更多工作机会。'},
            //     {hid: 'keyword', name: 'keyword', content: 'CIIP，建筑设计，设备租赁，劳动力'}
            // ]
        }
    }
})
export default class DemandList extends Vue {
    @Prop({
        type: Object
    }) item !: Object
    isShowBidding:boolean = false
    total: number = 0
    info: any = {}
    jsonList:any = {
        classId: '',
        sort: '',
        sortField: '',
        province: '',
        city: '',
        biddingDeadline: '',
        pageNumber: 1,
        pageSize: 9,
        name: ''
    }
    loading:boolean = false
    showNo:boolean = false
    dataList: any = []
    @Watch('$route', {immediate: true})
    routerchange () {
    }
    mounted () {
    }
    tofloat (val:any) {
        const num = parseFloat(val)
        let number = ''
        if (num < 10000) {
            number = (num / 1).toFixed(2) + '元'
        } else if (val === '') {
            number = '商议'
        } else {
            number = (num / 10000).toFixed(2) + '万元'
        }
        return number
    }
    telfn (val:any) {
        // const reg = /^(\d{3})\d{4}(\d{4})$/
        // let str = ''
        // str = val.replace(reg)
        const reg = /(\d{3})\d{4}(\d{4})/
        const tel1 = val.replace(reg, '$1****$2')
        return tel1
    }
    goDetail (val:any) {
        // 做未登录验证
        if (!this.$store.state.haslogin) {
            this.isShowBidding = false
            // this.dialogShow = true
            this.$message.warning('请先登录')
        } else {
            this.info = val
            this.isShowBidding = true
        }
    }
    dialogCallback (flag: boolean) {
        this.isShowBidding = flag
    }
    showoffer () {
        // console.log(123)
    }
    sizeCurrentChange (val:any) {
        console.log(val)
    }
    open53Server () {
        open53Server()
    }
}
</script>
<style lang="scss" scoped>
.containe{
    .much-btn {
        height: 72px;
        line-height: 72px;
    }
    .cont-bos{
        display: flex;
    }
    .img-qy{
        position: relative;
        top: 7px;
    }
    .left{
        position: absolute;
        z-index: 1;
    }
    .flrt-smile{
        font-size: 14px;
        color: black;
        .span-btn-item{
                    font-size: 14px;
                    color: #666;
                    margin-left: 10px;
                    .icon{
                        margin-right: 4px;
                    }
                    .icon-weixin_hover{
                        display: none;
                    }
                    &:hover{
                        color: #11a9e8;
                        .icon-weixin_hover{
                            display: inline-block;
                        }
                        .icon-weixin{
                            display: none;
                        }
                    }
                }
    }
    .elrow{
        width: 100%;
        height: 52px;
        line-height: 52px;
        background-color: #e3e3e3;
        border-radius: 4px;
        span {
            cursor: pointer;
        }
    }
    .f-box{
        position: relative;
    }
    .f-boxr{
        // position: relative;
    }
    .flleft{
        z-index: 2;
        position: absolute;
        left: 10px;
        color: #11a9e8;
        font-weight: 700;
        font-size: 20px;
    }
    .fllerg{
        z-index: 2;
        position: absolute;
        right: 50px;
        color: #11a9e8;
        font-size: 14px;
        font-weight: 700;
    }
    .fllefts{
        z-index: 2;
        position: absolute;
        right: 200px;
        font-size: 16px;
        color: #333333;
    }
    .fllergs{
        z-index: 2;
        position: absolute;
        right: 30px;
        font-size: 14px;
        color: #666666;
    }
    .content-body{
        cursor: pointer;
        min-height: 100px;
        width: 100%;
        background-color: #fff;
        border-radius: 4px;
        margin: 20px auto;
    }
    .allification{
        color: #11a9e8;
    }
    .firstLine{
        display: flex;
        width: 100%;
        height: 56px;
        line-height: 56px;
    }
    .firstLine>span{
        width: 100px;
        text-align: center;
        font-size: 14px;
    }
    .line{
        width: 96%;
        height: 1px;
        background-color: #f3f5f7;
        margin-left: 2%;
    }
        .content-father{
            border-radius: 3px;
            // width: 32.5%;
            background-color: #fff;
            margin: 5px;
        }
        .content-father:hover{
            // width: 32.5%;
            background-color: #fff;
            margin: 5px;
            box-shadow: 0px 3px 5px rgba(0,0,0,0.2);
        }
        .content-son{
            // display: flex;
            // flex-direction: column;
            // width: 344px;
            // height: 288px;
            // width: 100%;
            margin: 0 auto;
            padding: 20px;
            position: relative;
        }
        .authentication{
            display: inline-block;
            width: 65px;
            height: 24px;
            line-height: 24px;
            background-color: #a9d2c9;
            color: #fff;
            font-size: 12px;
            text-align: center;
            position: absolute;
            top: 0;
            // margin-right: 5px;
        }
        .house-day{
            margin-top: 10px;
            border-bottom: 1px solid #f3f5f7;
        }
        .house-day>span{
            display: inline-block;
            height: 40px;
            // width: 70px;
            line-height: 40px;
            text-align: center;
            font-size: 14px;
            // margin-left: -5px;
            margin-right: 10px;
            color: #b6b6b6;
            .sdays{
                // margin-right: 30px!important;
            }
        }
        .flspan{
            float: right;
        }
        .build-titles{
            width: 100%;
            height: 54px;
            line-height: 54px;
            color: black;
            // width: 100%;
            font-size: 16px;
            // margin-bottom: 20px;
            display: -webkit-box;
            -webkit-line-clamp: 1;
            overflow: hidden;
            line-break: normal;
            -webkit-box-orient: vertical;
            // text-align: center;
        }
        .nearnum{
            color: #b6b6b6;
            width: 100%;
            height: 42px;
            font-size: 14px;
            overflow : hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
        }
        .moneys{
            width: 100%;
            color: black;
            // height: 72px;
            // line-height: 72px;
        }
        .much{
            color: #ff5a5a;
            font-size: 22px;
            height: 30px;
            height: 36px;
            line-height: 36px;
        }
        .days{
            color: black;
            font-size: 14px;
            height: 26px;
            line-height: 26px;
        }
        // .address{
        //     color: black;
        //     float: right;
        //     margin-right: 15px;
        //     font-size: 16px;
        // }
        .span-btn-item{
                    font-size: 14px;
                    color: #666;
                    margin-left: 10px;
                    .icon{
                        margin-right: 4px;
                    }
                    .icon-weixin_hover{
                        display: none;
                    }
                    &:hover{
                        color: #11a9e8;
                        .icon-weixin_hover{
                            display: inline-block;
                        }
                        .icon-weixin{
                            display: none;
                        }
                    }
                }
        .addres{
            // float: right;
            color: black;
            margin-right: 15px;
            font-size: 16px;
        }
        .mybtn{
            width: 100px;
            height: 32px;
            background-color: #fff;
            color: #6cc1ee;
            border: 2px solid #6cc1ee;
            display: inline-block;
            line-height: 32px;
            text-align: center;
            border-radius: 4px;
            cursor: pointer;
        }
        .mybtn:hover{
            width: 100px;
            height: 32px;
            background-color: #6cc1ee;
            color: #fff;
            border: 2px solid #6cc1ee;
            display: inline-block;
            line-height: 32px;
            text-align: center;
            border-radius: 4px;
            cursor: pointer;
        }
        .company{
            width: 100%;
            height: 50px;
            background-color: #f3fbfe;
            border-radius: 0px 0px 4px 4px;
            margin-top: 24px;
            line-height: 50px;
            padding-left: 40px;
        }
    // }
}
.containe::v-deep li.number{
        margin: 0 5px;
        background-color:#fff;
        color: #606266;
        min-width: 30px;
        border-radius: 2px;
    }
</style>
